#pragma once
class GataLogic
{
public:
	GataLogic();
	~GataLogic();
	bool startServer(const int port, const  int workNum, const  int sessionNum, const  int read_timeout, const  int write_timeout);
	void stopServer();

	static DWORD WINAPI ThreadServer(LPVOID lPVOID);
	static DWORD WINAPI ThreadWorkers(LPVOID lPVOID);
	static DWORD WINAPI ThreadGameLogic(LPVOID lpVOID);
	static void DoAccept(struct evconnlistener *listener, evutil_socket_t fd, struct sockaddr *sa, int socklen, void *user_data);
	static void DoRead(struct bufferevent *bev, void *ctx);
	static void DoError(struct bufferevent *bev, short error, void *ctx);
	static void CloseSession(Session* pSession);
	static void handleNetPacket(Session* pSession);
	static void handleLoginPacket(Session* pSession, unsigned short cmd);

	
public:
	static CRITICAL_SECTION m_ReadLock;
	bool m_boQuitGame;
	Server m_Server;
	HANDLE   m_Handle;

};
